package com.atguigu.gmall.product.controller;/*
 * @author: XueYouPeng
 * @time: 23.7.13 上午 10:20
 */

import com.atguigu.gmall.common.result.Result;

import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.product.dto.SpuInfoDto;
import com.atguigu.gmall.product.service.SpuInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/admin/product")
public class SpuInfoController {

    @Autowired
    private SpuInfoService spuInfoService;

    /*
     * 获取spu分页列表
     * @author: XueYouPeng
     * @time: 23.7.13 上午 10:21
     */
     @GetMapping(value = "/{page}/{limit}")
     public Result<Page> findByPage(
             @PathVariable(value = "page") Integer pageNum,
             @PathVariable(value = "limit") Integer pageSize,
             @RequestParam(value = "category3Id") Long category3Id
     ){
        Page page = spuInfoService.findByPage(pageNum,pageSize,category3Id);
        return Result.build(page, ResultCodeEnum.SUCCESS);
     }

    /*
     * 添加spu
     * @author: XueYouPeng
     * @time: 23.7.13 上午 11:45
     */
     @PostMapping(value = "/saveSpuInfo")
     public Result saveSpuInfo(@RequestBody SpuInfoDto spuInfoDto){
         spuInfoService.saveSpuInfo(spuInfoDto);
         return Result.build(null,ResultCodeEnum.SUCCESS);
     }
}
